<template>
  <div class="goods" @click="itemclice">
      <!-- 懒加载 -->
      <img v-lazy="showImage" :key="showImage" alt="">
      <div class="goods-info">
          <p>{{goodsitem.title}}</p>
          <span class="price">{{goodsitem.price}}</span>
           <span class="collect">{{goodsitem.cfav}}</span>
      </div>
  </div>
</template>

<script>
export default {
    name:"GoodsListItem",
    props:{
        goodsitem:{
            type:Object,
            default(){
                return {}
            }
        }
    },
    methods:{
        itemclice(){
            this.$router.push('/detail/' + this.goodsitem.iid)
        }
    },
    computed:{
        // 判断选择路径
        showImage(){
            return this.goodsitem.image || this.goodsitem.show.img
        }
    }
}
</script>

<style>
.goods{
    padding-bottom: 40px;
    position: relative;
    flex: 45%;
}
.goods img{
    width: 95%;
    border-radius: 5px;
}
.goods-info{
    font-size: 12px;
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    overflow: hidden;
    text-align: center;

}
.goods-info p{
    overflow: hidden;
    /* 省略 */
    text-overflow: ellipsis;
    /* 设置一行显示 */
    white-space: nowrap;
    margin-bottom: 3px;
}
.goods-info .price{
    color: var(--color-high-text);
    margin-right:70px ;
}
.goods-info .collect{
    position: relative;
    margin-left:60px ;
}
.goods-info .collect::after{
    content: "";
    display: block;
    position: absolute;
    left: -15px;
    top: -1px;
    width: 14px;
    height: 14px;
    background: url('../../../assets/img/home/sc.png');
    background-size: 14px 14px;
}
</style>